'use strict';

const BaseController = require('../sys/base');
const qiniu = require('../../utils/qiniu');
const await = require('await-stream-ready/lib/await');

/**
 * 部门管理
 */
class departmentController extends BaseController {

  async add() {
    const { ctx } = this;
    let postData = ctx.request.body;
    let result = await ctx.service.organization.department.add(postData);
    this.success(result);
  }

  async list() {
    const { ctx } = this;
    const query = ctx.request.query;
    let result = await ctx.service.organization.department.list(query);
    this.success(result);
  }

  async update() {
    const { ctx } = this;
    const requestData = ctx.request.body;
    let result = await ctx.service.organization.department.update(requestData);
    this.success(result);
  }

  async delete() {
    const { ctx } = this;
    const requestData = ctx.request.query;
    const result = await ctx.service.organization.department.delete(requestData);
    this.success(result);
  }

}

module.exports = departmentController;
